﻿@model NVSecurity.Models.News

@{
    ViewBag.Title = "Create";
    string types = ViewBag.type;
}
<script src="~/nicEditor/nicEdit.js"></script>
<script>
    bkLib.onDomLoaded(function () {
        new nicEditor({ fullPanel: true, uploadURI: '/@NVSecurity.Models.GlobalVariables.PathFolderName/Home/nicUpload' }).panelInstance('area');

    });
    bkLib.onDomLoaded(function () {
        new nicEditor({ fullPanel: true, uploadURI: '/@NVSecurity.Models.GlobalVariables.PathFolderName/Home/nicUpload' }).panelInstance('area1');

    });
    bkLib.onDomLoaded(function () {
        new nicEditor({ fullPanel: true, uploadURI: '/@NVSecurity.Models.GlobalVariables.PathFolderName/Home/nicUpload' }).panelInstance('area2');

    });
</script>
@using (Html.BeginForm("Create", "News", FormMethod.Post, new { id = "FormCreateNews", type = types, enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)
    <div class="mar10 borall">
        <div class="floatl">
            <span class="floatl">
                <img src="/Areas/Admin/images/icon-48-generic.png" /></span>
            <span class="title-name">Thêm mới</span>
        </div>
        <ul class="floatr toolbar-list">
            <li id="toolbar-cancel" class="button">
                <a class="toolbar" href="/@NVSecurity.Models.GlobalVariables.PathFolderName/News/Index">
                    <span class="icon-32-cancel"></span>
                    Hủy bỏ
                </a>
            </li>
            <li class="button">
                <div class="toolbar">
                    <span class="icon-32-apply"></span>
                    <input type="submit" value="Lưu" />
                </div>
            </li>
        </ul>
    </div>
    <!--end borall-->
 
    <div class="clear0"></div>
    <div class="mar10 borall">
        <div class="div100">
            <div>
                <fieldset class="fromlist">
                    <ul>

                        <li>
                            @Html.LabelFor(model => model.Title, "Tiêu đề")
                            @Html.TextBoxFor(model => model.Title, new { size = "70", @id = "tilte" })
                            @Html.ValidationMessageFor(model => model.Title, null, new { @class = "validate" })
                            <span id="TitleError" style="color: red"></span>
                        </li>                                                 
                        <li>
                            <label style="color: green">Hình ảnh</label>
                            <input type="file" name="img1" />
                        </li>
                        <li>
                            @Html.LabelFor(model => model.ShortDescripion, "Mô tả ngắn")<span class="start">*</span>
                            @Html.TextAreaFor(model => model.ShortDescripion, new { cols = "55", rows = "10", @id = "ShortDes" })
                            @Html.ValidationMessageFor(model => model.ShortDescripion, null, new { @class = "validate" })
                        </li>
                        <p id="ShortDesError" style="color: red"></p>

                        <p id="areaError" style="color: red">@ViewBag.DesError</p>
                        <li>
                            <div style="width: 470px">@Html.ValidationMessageFor(model => model.Description, null, new { @class = "validate" })
                                @Html.LabelFor(model => model.Description, "Nội dung")
                                <div style="margin-left: 245px">
                                    @Html.TextAreaFor(model => model.Description, new { @id = "area", rows = 20, clos = 55, style = "Width:800px;", @class = "Descriptionvali" })

                                </div>
                               
                            </div>
                        </li>
@*                         <li>
                            @Html.LabelFor(model => model.MetaTitle, "Meta Title")
                            @Html.TextBoxFor(model => model.MetaTitle, new { size = "70", @id = "tilte" })
                       
                        </li>
                         <li>
                            @Html.LabelFor(model => model.MetaKeywork, "Meta KeyWord")
                            @Html.TextBoxFor(model => model.MetaKeywork, new { size = "70", @id = "tilte" })
                        
                        </li>
                          <li>
                            @Html.LabelFor(model => model.MetaDescription, "Meta Description")<span class="start">*</span>
                            @Html.TextAreaFor(model => model.MetaDescription, new { cols = "55", rows = "10", @id = "ShortDes" })                    
                        </li>*@
                    </ul>

                </fieldset>
            </div>
        </div>
    </div>
    
}
<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
</script>
<script type="text/javascript">
    function CheckNull() {

        var tilte = document.getElementById('tilte').value;
        var ShortDes = document.getElementById('ShortDes').value;
        //var area = document.getElementById('area').value;


        if (tilte == "" || ShortDes == "") {
            if (tilte == "") {
                document.getElementById("TitleError").innerHTML = "Vui lòng Nhập Liệu";
                document.getElementById("tilte").focus();
            }
            //if (ShortDes == "") {
            //    document.getElementById("ShortDesError").innerHTML = "Vui lòng nhập 'Mô tả ngắn'";
            //    document.getElementById("ShortDes").focus();
            //}
            if (area == "") {
                document.getElementById("areaError").innerHTML = "Vui lòng nhập Liệu";
                document.getElementById("area").focus();
            }

            return false;


        }
        return true;


    }
</script>

<script type="text/javascript">
    $('#FormCreateNews').submit(function () {
        return CheckNull();
    });
</script>

